let __timerId = 0
let time = 0

// 打开全局定时器
export function openTime() {
  closeTime()
  __timerId = setInterval(() => {
    time += 1
  }, 1000)
}

export function closeTime() {
  // 关闭定时器
  if (__timerId !== 0) {
    clearInterval(__timerId)
    __timerId = 0
    time = 0
  }
}

export function getTime() {
  return time
}
